﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace AuSys.Database.Context.Specific
{
    public class DataSqlServerContext(
        DataContextOptions options
        ) : DataContext(options)
    {
        public const string dbType = "sqlserver";
        public override string AcceptDbType => dbType;
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            Action<SqlServerDbContextOptionsBuilder> action = x => { };
            if (_options.SqlServer is not null && _options.SqlServer.CompatibilityLevel > 0)
                action = x => x.UseCompatibilityLevel(_options.SqlServer.CompatibilityLevel);

            optionsBuilder.UseSqlServer(_options.ConnStr, action);
        }
    }
}
